/**
 * create by Sun
 * 2018/7/29
 */

import com.sun.beans.MainImg;
import com.sun.beans.SonImg;
import com.sun.dao.MainImgMapper;
import com.sun.dao.SonImgMapper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.nio.charset.MalformedInputException;

/**
 * 配置spring和junit整合，junit启东市加载SpringIoc容器
 */
@RunWith(SpringJUnit4ClassRunner.class)
//告诉junit spring配置文件的位置
//在这个contextconfiguration下的classpath下不能添加 springmvc的 配置文件，添加springmvc的配置文件会加载不过来无法转换handler
@ContextConfiguration({"classpath:ssm/spring-service.xml"})
public class BaseDao {
    @Autowired
    private MainImgMapper mainImgMapper;
    @Autowired
    private SonImgMapper sonImgMapper;
    @Autowired

    @Test
    public void test(){
        System.out.println(mainImgMapper);
        MainImg mainImg = mainImgMapper.selectByPrimaryKey(1);
        System.out.println(mainImg.getmId()+" "+mainImg.getmName());
        SonImg sonImg = sonImgMapper.selectByPrimaryKey(1);
        System.out.println(sonImg.getmId());

    }

}
